<html xmlns:th="http://www.thymeleaf.org">
<link type="text/css" href="/topjui/css/myui.css" rel="stylesheet"/>
<form id="customerform" method="post" style="padding-top:1px">
    <input type="hidden" id="id" name="id" value="0">
    <input type="hidden" id="skuid" name="skuid" value="0">
    <input type="hidden" id="type" name="type" value="JD">
    <table class="editTable">
        <tr>
            <td class="label">商品名称</td>
            <td colspan="3">
                <input type="text" name="goodsname" autocomplete="off" class="inputp" data-options="required:true" style="width: 678px;">
            </td>
        </tr>
        <tr>
            <td class="label">商品类型</td>
            <td>
                <input type="text" name="typeid" autocomplete="off" title="请输入ID" class="inputp" data-options="required:true" style="width: 40px;">
                <input type="text" name="typename" autocomplete="off" class="inputp" data-options="required:true" style="width: 156px;">
                <input type="button" id="findtype" name="findtype" class="l-btn topjui-btn-normal l-btn-small" value="查询" style="width: 56px">
            </td>
            <td class="label">子类类型</td>
            <td>
                <input type="text" name="subtypeid" autocomplete="off" title="请输入ID" class="inputp" data-options="required:true" style="width: 40px;">
                <input type="text" name="subtypename" autocomplete="off" class="inputp" data-options="required:true" style="width: 156px;">
                <input type="button" id="findsub" name="findsub" class="l-btn topjui-btn-normal l-btn-small" value="查询" style="width: 56px">
            </td>
        </tr>
        <tr>
            <td class="label">市场价</td>
            <td>
                <input type="text" name="price" autocomplete="off" class="inputp" data-options="required:true" style="width: 290px;">
            </td>
            <td class="label">售价</td>
            <td>
                <input type="text" name="sellprice" autocomplete="off" class="inputp" data-options="required:true" style="width: 290px;">
            </td>
        </tr>
        <tr>
            <td class="label">商品货号</td>
            <td>
                <input type="text" id="goodsno" name="goodsno" autocomplete="off" class="inputp" data-options="required:true" style="width: 216px;">
                <input type="button" id="newno" name="newno" class="l-btn topjui-btn-normal l-btn-small" value="生成货号" style="width: 66px">
            </td>
            <td class="label">库存数量</td>
            <td>
                <input type="text" name="goodssum" autocomplete="off" class="inputp" data-options="required:true" style="width: 290px;">
            </td>
        </tr>
        <tr>
            <td class="label">是否上架</td>
            <td>
                <select name="downstate" style="width: 300px;" class="selectp">
                    <option value="1">是</option>
                    <option value='0' selected>否</option>
                </select>
            </td>
            <td class="label">品牌</td>
            <td>
                <input type="text" name="brandId" autocomplete="off" title="请输入ID" class="inputp" data-options="required:true" style="width: 40px;">
                <input type="text" name="brand" autocomplete="off" class="inputp" data-options="required:true" style="width: 156px;">
                <input type="button" id="findbrand" name="findbrand" class="l-btn topjui-btn-normal l-btn-small" value="查询" style="width: 56px">
            </td>
        </tr>
        <tr>
            <td class="label">商品图片</td>
            <td class="label" colspan="3"></td>
        </tr>
        <tr>
            <td colspan="4">
                <table width="100%">
                    <tr>
                        <td width="90%"><textarea id="goodspic" name="goodspics" style="padding: 4px;width:689px;height: 79px"></textarea></td>
                        <td><input type="button" id="findpic" name="findpic" class="l-btn topjui-btn-normal l-btn-small" value="查看" style="width: 66px"></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="label">图片预览</td>
            <td>
                <input type="text" id="baseurl" name="baseurl" value="http://dataizhou.top/" autocomplete="off" class="inputp" data-options="required:false" style="width: 290px;">
            </td>
            <td colspan="2">
                <input type="text" id="goodsimg" name="goodsimg" autocomplete="off" class="inputp" data-options="required:true" style="width: 290px;">
                <input type="button" id="chapincx" name="chapincx" class="l-btn topjui-btn-normal l-btn-small" value="预览图片" style="width: 66px">
            </td>
        </tr>
        <tr>
            <td class="label">商品详情</td>
            <td class="label" colspan="3"></td>
        </tr>
        <tr>
            <td colspan="4">
                <textarea id="context" name="context" style="padding: 4px;width:766px;height: 140px"></textarea>
            </td>
        </tr>
    </table>
    <script th:inline="javascript">
        $(function () {
            $("#newno").on('click',function (event){
                $.ajax({
                    url: '/jdgoods/newno',
                    dataType: 'json',
                    success: function (r) {
                        if (r.code == '200') {
                            $("#goodsno").val(r.result)
                        }
                    }
                });
            });

            $("#findtype").on('click',function (event){
                var typename = $("input[name='typename']").val();
                $.ajax({
                    url: '/jdgoods/findtype',
                    data:{'typename':typename},
                    dataType: 'json',
                    success: function (r) {
                        if (r.code == '200') {
                            $("input[name='typeid']").val(r.result)
                        }
                        if(r.code == '500') {
                            $.messager.alert('提示', r.message);
                        }
                    }
                });
            });

            $("#findsub").on('click',function (event){
                var typename = $("input[name='subtypename']").val();
                $.ajax({
                    url: '/jdgoods/findtype',
                    data:{'typename':typename},
                    dataType: 'json',
                    success: function (r) {
                        if (r.code == '200') {
                            $("input[name='subtypeid']").val(r.result)
                        }
                        if(r.code == '500') {
                            $.messager.alert('提示', r.message);
                        }
                    }
                });
            });

            $("#findbrand").on('click',function (event){
                var brand = $("input[name='brand']").val();
                $.ajax({
                    url: '/jdgoods/findbrand',
                    data:{'brand':brand},
                    dataType: 'json',
                    success: function (r) {
                        if (r.code == '200') {
                            $("input[name='brandId']").val(r.result)
                        }
                        if(r.code == '500') {
                            $.messager.alert('提示', r.message);
                        }
                    }
                });
            });

            $("#findpic").on('click',function (event){
                var uid = $("#skuid").val();
                $.ajax({
                    url: '/jdgoods/findpic',
                    data:{'uid':uid},
                    dataType: 'json',
                    success: function (r) {
                        if (r.code == '200') {
                            $("#goodspic").val(r.result)
                        }
                    }
                });
            });

            $("#chapincx").on('click',function (event){
                var picsrc = $('#baseurl').val()+$('#goodsimg').val();
                $('<div/>').dialog({
                    href : "/jdgoods/picyl?picsrc="+picsrc,
                    width : 400,
                    height : 360,
                    modal : true,
                    title : '图片预览'
                });
            });

        });


    </script>
</form>
</html>